<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:c="http://java.sun.com/jstl/core"
      xmlns:s="http://jboss.com/products/seam/taglib"
      xmlns:a="http://richfaces.org/a4j"
      xmlns:r="http://richfaces.org/rich"
      xmlns:m="http://www.caradvert.com/main">

<ui:composition>

    <h:panelGroup layout="block" rendered="#{not empty advert}">

        <c:set var="nameStyle" value="text-align:right;font-size:9pt;"/>
        <c:set var="middleStyle" value="width:100px;border-bottom-style:dotted;border-width:1px;border-color:gray;"/>
        <c:set var="valueStyle" value="text-align:left;font-weight:bold;font-size:9pt;"/>

        <table width="100%;">
            <tr>
                <td valign="top">
                    <table width="100%;">
                        <tr>
                            <td colspan="3" class="lj" style="padding:0 0 25px 5px;font-size:8pt;font-weight:bold;">
                                <h:outputLink value="#{backUrl}">
                                    &#60;&#60;&#160;#{labels['BACK']}
                                </h:outputLink>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3" class="cj" style="padding-bottom:20px;color:#006666;font-weight:bold;">
                                #{labels['PRICE']} &#160;
                                <h:outputText value="#{advert.price}" converter="currency"
                                              rendered="#{not empty advert.price}"/>
                                <h:outputText value="&#160;#{labels[advert.currency.name]}"
                                              rendered="#{not empty advert.price}"/>
                                <h:outputText value="#{labels['AGREEMENT']}"
                                              rendered="#{empty advert.price}"/>
                            </td>
                        </tr>
                        <tr>
                            <td style="#{nameStyle}">
                                #{labels['CATEGORY']}
                            </td>
                            <td style="#{middleStyle}">
                                &#160;
                            </td>
                            <td style="#{valueStyle}">
                                #{labels[advert.vehicle.category.name]}
                            </td>
                        </tr>
                        <tr>
                            <td style="#{nameStyle}">
                                #{labels['BRAND']}
                            </td>
                            <td style="#{middleStyle}">
                                &#160;
                            </td>
                            <td style="#{valueStyle}">
                                <h:outputText value="#{advert.vehicle.brand.name}" rendered="#{not empty advert.vehicle.brand}"/>
                                <h:outputText value="#{advert.vehicle.brandName}" rendered="#{empty advert.vehicle.brand}"/>
                            </td>
                        </tr>
                        <tr>
                            <td style="#{nameStyle}">
                                #{labels['MODEL']}
                            </td>
                            <td style="#{middleStyle}">
                                &#160;
                            </td>
                            <td style="#{valueStyle}">
                                <h:outputText value="#{advert.vehicle.model.name}" rendered="#{not empty advert.vehicle.brand}"/>
                                <h:outputText value="#{advert.vehicle.modelName}" rendered="#{empty advert.vehicle.brand}"/>
                            </td>
                        </tr>
                        <tr>
                            <td style="#{nameStyle}">
                                #{labels['RELEASE_YEAR']}
                            </td>
                            <td style="#{middleStyle}">
                                &#160;
                            </td>
                            <td style="#{valueStyle}">
                                #{advert.vehicle.releaseYear}
                            </td>
                        </tr>
                        <tr>
                            <td style="#{nameStyle}">
                                #{labels['STATE']}
                            </td>
                            <td style="#{middleStyle}">
                                &#160;
                            </td>
                            <td style="#{valueStyle}">
                                <h:outputText value="#{labels[advert.vehicle.state.name]}"
                                              rendered="#{not empty advert.vehicle.stateCode}"/>
                                <h:outputText value="#{labels['NOT_SPECIFIED']}"
                                              rendered="#{empty advert.vehicle.stateCode}"/>
                            </td>
                        </tr>
                        <tr>
                            <td style="#{nameStyle}">
                                #{labels['MILEAGE']}
                            </td>
                            <td style="#{middleStyle}">
                                &#160;
                            </td>
                            <td style="#{valueStyle}">
                                <h:outputText value="#{advert.vehicle.mileage}"
                                              converter="integer" rendered="#{not empty advert.vehicle.mileage}"/>
                                <h:outputText value="&#160;#{labels['KM']}" rendered="#{not empty advert.vehicle.mileage}"/>
                                <h:outputText value="#{labels['NOT_SPECIFIED']}"
                                              rendered="#{empty advert.vehicle.mileage}"/>
                            </td>
                        </tr>
                        <tr>
                            <td style="#{nameStyle}">
                                #{labels['REGION']}
                            </td>
                            <td style="#{middleStyle}">
                                &#160;
                            </td>
                            <td style="#{valueStyle}">
                                <h:outputText value="#{advert.region.name}"
                                              rendered="#{not empty advert.regionCd}"/>
                                <h:outputText value="#{labels['NOT_SPECIFIED']}"
                                              rendered="#{empty advert.regionCd}"/>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">&#160;</td>
                        </tr>
                        <h:panelGroup rendered="#{not empty advert.description}">
                            <tr>
                                <td colspan="3" style="padding-left:40px;">
                                    <fieldset class="advertDesc">
                                        <legend>#{labels['DESCRIPTION']}:</legend>
                                        <span style="font-size:8pt;">
                                            <m:html value="#{advert.description}"/>
                                        </span>
                                    </fieldset>
                                </td>
                            </tr>
                        </h:panelGroup>
                        <h:panelGroup rendered="#{not empty advert.contactInfo}">
                            <tr>
                                <td colspan="3" style="padding-left:40px;">
                                    <fieldset class="advertDesc">
                                        <legend>#{labels['CONTACT_INFO']}:</legend>
                                        <span style="font-size:8pt;">
                                            <m:html value="#{advert.contactInfo}"/>
                                        </span>
                                    </fieldset>
                                </td>
                            </tr>
                        </h:panelGroup>
                    </table>
                </td>
                <td valign="top" class="cj" style="width:#{config.imageConfig.previewWidth}px;">
                    <table width="100%;">
                        <tr>
                            <td style="font-size:8pt;color:dimgray;">
                                <h:outputText value="#{labels['CLICK_TO_ENLARGE']}" rendered="#{advert.images.size gt 0}"/>
                                <h:outputText value="#{labels['NO_PHOTO']}" rendered="#{advert.images.size eq 0}"/>
                            </td>
                        </tr>
                        <ui:repeat value="#{advert.images}" var="image">
                            <tr>
                                <td>
                                    <h:outputLink value="#{config.imageConfig.uploadedUri}/#{image.id}.jpg" rel="lightbox">
                                        <h:graphicImage styleClass="thumbnail" url="#{config.imageConfig.uploadedUri}/#{image.id}_preview.jpg" title="#{labels['CLICK_TO_ENLARGE']}"/>
                                    </h:outputLink>
                                </td>
                            </tr>
                        </ui:repeat>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="2">&#160;</td>
            </tr>
            <tr style="font-size:7pt;font-weight:bold;;color:gray;">
                <td colspan="2" class="rj">
                    #{labels['PUBLISHED']}&#160;
                    <h:outputText value="#{advert.advertDate}">
                        <f:convertDateTime pattern="dd.MM.yyyy"/>
                    </h:outputText>
                </td>
            </tr>
        </table>
    </h:panelGroup>

</ui:composition>

</html>